<template>
  <div class='like'>
    <Card>
      <span>猜你喜欢</span>
    </Card>
    <ul>
      <li
        v-for='(item,index) in likeList'
        :key='index'
        @click="goDetail(item.id)"
      >
        <h2>
          <!-- v-lazy直接这样写 不用：v-lazy -->
          <img
            v-lazy="item.imgUrl"
            :alt="item.imgUrl"
          >
        </h2>
        <h3>{{item.name}}</h3>
        <div>
          <span>¥</span>
          <b>{{item.price}}</b>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
/* import Card from "@/components/home/Card.vue"; */
import Card from "../../components/home/Card.vue"; //引入card
//import { Lazyload } from "mint-ui"; 懒加载 不用import
export default {
  props: {
    likeList: Array, //接收  父组件传递到子组件的数据
  },
  // data() {
  // return {};
  //},
  components: {
    Card,
  },
  methods: {
    goDetail(id) {
      this.$router.push({
        path: "/detail" /*显式传递*/,
        query: {
          id /* id: id,  显式传递*/,
        }, //下面隐式传递
        //name: "Detail",
        //params: {
        //  id: id,
        //},
      });
    },
  },
};
</script>

<style scoped>
.like ul {
  /* 图片 */
  display: flex;
  /* 换行 */
  flex-wrap: wrap;
}
.like ul li {
  display: flex;
  flex-direction: column;
  justify-content: center; /* 居中 */
  align-items: center;
  width: 50%; /* 一行两个 */
  text-align: center;
  /*   padding: 0.6px; */
}
.like h3 {
  /*   padding: 0 6px; */
  width: 93%; /* 文字 免得顶边框*/
  font-size: 16px;
  font-weight: 400; /* 字体粗细 */
  color: rgb(44, 42, 42);
  overflow: hidden;
  text-overflow: ellipsis; /* 单行文字隐藏 */
  white-space: nowrap;
}
.like ul li > div {
  width: 93%;
  padding: 6px;
  text-align: left;
  /*   text-align: center; */
  color: #ff0000;
}
/* 金钱￥ */
/* like ul li > div span */
.like ul li > div span {
  font-size: 12px;
}
/* 文字 */
.like ul li > div b {
  font-weight: 600;
  font-size: 16px;
  color: #e96565;
}
.like img {
  width: 176px;
  height: 176px;
}
/* 懒加载默认样式 */
.like img [lazy="loading"] {
  width: 176px;
  height: 176px;
  margin: auto;
}
</style>
